package com.jy.rhin.support.polymorphism.convertor;

import cn.org.chiss.rhin._2015.document.management.DocumentStoredQueryResponse;
import com.jy.rhin.sdk.dto.document.DocumentFolderDto;
import com.jy.rhin.sdk.dto.document.DocumentResultDto;
import com.jy.rhin.sdk.dto.document.query.GetFolderAndContentsDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author dhl
 * @date 2022/6/22
 * @Description
 */
@Service("getFolderAndContents")
public class DocumentQueryHandler4GetFolderAndContents extends AbstractDocumentQueryHandler<GetFolderAndContentsDto, DocumentFolderDto>{
    @Override
    GetFolderAndContentsDto convertReq(Map<String, List<String>> dtoValueMap) {
        GetFolderAndContentsDto dto = new GetFolderAndContentsDto();
        dto.setId(QueryValueUtils.getStringValue("$FolderUUID", dtoValueMap));
        dto.setUniqueId(QueryValueUtils.getStringValue("$FolderUniqueId", dtoValueMap));
        dto.setHomeCommunityId(QueryValueUtils.getStringValue("$HomeCommunityId", dtoValueMap));
        dto.setFormatCodeList(QueryValueUtils.getListValue("$DocumentEntryFormatCode", dtoValueMap));
        dto.setConfidentialityCodeList(QueryValueUtils.getListValue("$DocumentEntryConfidentialityCode", dtoValueMap));
        return dto;
    }

    @Override
    DocumentResultDto<DocumentFolderDto> query(GetFolderAndContentsDto dto) {
        return documentSubmissionQueryHandler.getFolderAndContents(dto);
    }

    @Override
    DocumentStoredQueryResponse convertResp(List<DocumentFolderDto> resultList, List<String> jsonTextList) {
        return folderConvert(resultList, jsonTextList);
    }
}
